home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / stamps1 / stamps.pas < prev    next >
Pascal/Delphi Source File  |  1995-12-22  |  2KB  |  88 lines

  1. unit Stamps;
  2. {This TTimeStamp Component shows the Application Compile Date as a
  3.  DateTime string or number simply by changing the Display property.
  4.  In the Design mode it shows '12/31/99 12:59:58 PM' or '664758141'.
  5.  It has all the propreties of a TLabel except Caption is not published.
  6.  Put one on your About Dialog and you have instant version control.
  7.  By Bill Murto, CIS 73730,2505. No Copyright. No Fee. No Guarantee. Enjoy!}
  8. interface
  9.  
  10. uses
  11.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  12.   Forms, Menus, StdCtrls;
  13.  
  14. type
  15.   TTimeStampDisplayType = (dtString, dtNumber);
  16.   TTimeStamp = class(TCustomLabel)
  17.   private
  18.     { Private declarations }
  19.     fDisplay: TTimeStampDisplayType;
  20.     procedure SetDisplay(Value: TTimeStampDisplayType);
  21.   protected
  22.     { Protected declarations }
  23.   public
  24.     { Public declarations }
  25.     constructor Create(AOwner: TComponent); override;
  26.   published
  27.     { Published declarations }
  28.     property Align;
  29.     property Alignment;
  30.     property AutoSize;
  31.     property Color;
  32.     property Display: TTimeStampDisplayType read fDisplay write SetDisplay default dtString;
  33.     property DragCursor;
  34.     property DragMode;
  35.     property Enabled;
  36.     property FocusControl;
  37.     property Font;
  38.     property ParentColor;
  39.     property ParentFont;
  40.     property ParentShowHint;
  41.     property PopupMenu;
  42.     property ShowAccelChar;
  43.     property ShowHint;
  44.     property Transparent;
  45.     property Visible;
  46.     property WordWrap;
  47.     property OnClick;
  48.     property OnDblClick;
  49.     property OnDragDrop;
  50.     property OnDragOver;
  51.     property OnEndDrag;
  52.     property OnMouseDown;
  53.     property OnMouseMove;
  54.     property OnMouseUp;
  55. end;
  56.  
  57. procedure Register;
  58.  
  59. implementation
  60.  
  61. procedure Register;
  62. begin
  63.   RegisterComponents('Samples', [TTimeStamp]);
  64. end;
  65.  
  66. constructor TTimeStamp.Create(AOwner: TComponent);
  67. begin
  68.   inherited Create(AOwner);
  69.   SetDisplay(dtString);
  70. end;
  71.  
  72. procedure TTimeStamp.SetDisplay(Value: TTimeStampDisplayType);
  73. begin
  74.   fDisplay := Value;
  75.   if csDesigning in ComponentState then
  76.     case fDisplay of
  77.       dtString: Caption := '12/31/99 12:59:58 PM';
  78.       dtNumber: Caption := '664758141';
  79.     end
  80.   else
  81.     case fDisplay of
  82.       dtString: Caption := DateTimeToStr(FileDateToDateTime(Fileage(Application.ExeName)));
  83.       dtNumber: Caption := IntToStr(Fileage(Application.ExeName));
  84.     end;
  85. end;
  86.  
  87. end.
  88.